package com.joysuch.wwyt.bp.entity.inspect;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.joysuch.wwyt.bp.bean.inspect.BpInspectPlanDeviceDto;
import com.joysuch.wwyt.core.support.AutoSetCommonFieldListener;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

import static javax.persistence.GenerationType.IDENTITY;

/**
 * 巡检-检查计划管理-巡检点
 */
@Data
@Entity
@EntityListeners({AuditingEntityListener.class, AutoSetCommonFieldListener.class})
@Table(name = "WWYT_BP_INSPECT_PLAN_CHECK_POINT")
@SQLDelete(sql = "update WWYT_BP_INSPECT_PLAN_CHECK_POINT set DELETE_FLAG = '1' where id= ?")
@SQLDeleteAll(sql = "update WWYT_BP_INSPECT_PLAN_CHECK_POINT set DELETE_FLAG = '1' where id= ?")
@Where(clause = "DELETE_FLAG = '0'")
public class BpInspectPlanCheckPoint implements Serializable {

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @ApiModelProperty("主键ID")
    private Long id;

    @ApiModelProperty("检查计划表id")
    private Long inspectPlanId;

    @ApiModelProperty("检查点管理表id")
    private Long pointId;

    @ApiModelProperty("检查点名称")
    private String name;

    @ApiModelProperty("检查点类型")
    private String type;

    @ApiModelProperty("设备数量")
    @Transient
    private Integer deviceCount;

    @ApiModelProperty("检查数量-项目数量")
    private Integer count;

    @ApiModelProperty("检查开始时间-检查记录业务用到")
    private LocalDateTime checkStartTime;

    @ApiModelProperty("检查结束时间-检查记录业务用到")
    private LocalDateTime checkFinishTime;

    @ApiModelProperty("定位位置")
    @Transient
    private String inspectLocation;

    @ApiModelProperty("定位方式")
    @Transient
    private String locationType;

    @ApiModelProperty("检查点下设备集合")
    @Transient
    private List<BpInspectPlanDeviceDto> deviceDtoList;


    //通用字段
    @ApiModelProperty("创建人")
    @org.springframework.data.annotation.CreatedBy
    @JsonIgnore
    private Long createBy;

    @ApiModelProperty("创建时间")
    @org.springframework.data.annotation.CreatedDate
    private java.time.LocalDateTime createTime;

    @ApiModelProperty("更新人")
    @org.springframework.data.annotation.LastModifiedBy
    @JsonIgnore
    private Long updateBy;

    @ApiModelProperty("更新时间")
    @org.springframework.data.annotation.LastModifiedDate
    private java.time.LocalDateTime updateTime;

    @ApiModelProperty("租户")
    private Long tenentId;

    @ApiModelProperty("组织机构代码")
    private String orgCode;

    @ApiModelProperty("删除标记")
    @JsonIgnore
    private String deleteFlag;
}
